/*
 * world_boss.h
 *
 *  Created on: Feb 11, 2014
 *      Author: killerg
 */

#ifndef WORLD_BOSS_H_
#define WORLD_BOSS_H_

#include "share/patterns.h"
struct level_t;
typedef shared_ptr<level_t> sp_level_t;

struct world_boss_t {
	struct rank_item_t {
		string name;
		int64_t playerid = -1;
		int32_t damage = 0;
		int32_t rank_damage = 0;
		int32_t combat_time = 0;
		int32_t rank = -1;
	};
	typedef shared_ptr<rank_item_t> sp_rank_item_t;

	enum state_t {
		RESTING = 0,	// 修整
		COMBATING = 1,	// 战斗
		REWARDING = 2,	// 发奖励
	};

	// -------------------------------------------------
	int boss_levelid = -1;
	int cur_hp = 0;
	state_t status = RESTING;
	bool turnon = false;
	int finish = -1;
	int32_t reward_index = -1;
	int level = 20;

	// -------------------------------------------------
	int64_t last_attack = -1;
	ptr_map<int64_t, sp_rank_item_t, std::unordered_map<int64_t, sp_rank_item_t> > data;
	vector<sp_rank_item_t> rank;
	double rank_timer = -1.0f;
	bool rank_chg = false;

	bool init();
	void destroy();
	void update();

	void _post_save_data();
	void _post_save_status();

	int32_t get_max_hp();
	bool _gen_boss();
	sp_level_t boss;
	struct comp {
		bool operator()(const sp_rank_item_t lhs, const sp_rank_item_t rhs) const {
			return lhs->rank_damage > rhs->rank_damage;
		}
	};

};



#endif /* WORLD_BOSS_H_ */
